package library.operation;

import library.BookList;
import library.Book;

import java.util.Scanner;

public class FindOperation implements IOperation {
    @Override
    public void work(BookList bookList){
        System.out.println("查找操作");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入书名：");
        String name = scanner.next();
        //遍历整个书籍列表，依次取出每个书籍，判定书名是否一致，一致则进行打印
        for (int i = 0; i < bookList.getSize(); i++) {
            Book book = bookList.getBook(i);
            if (book.getName().equals(name)){
                System.out.println(book);
            }
        }
        System.out.println("查找完毕");
    }
}
